import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UpkeepTemplateForm, UpkeepTemplateQuery, UpkeepTemplateVO } from '@/api/iot/upkeepTemplate/types';

/**
 * 查询电梯保养模板列表
 * @param query
 * @returns {*}
 */

export const listUpkeepTemplate = (query?: UpkeepTemplateQuery): AxiosPromise<UpkeepTemplateVO[]> => {
  return request({
    url: '/iot/upkeepTemplate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询电梯保养模板详细
 * @param templateId
 */
export const getUpkeepTemplate = (templateId: string | number): AxiosPromise<UpkeepTemplateVO> => {
  return request({
    url: '/iot/upkeepTemplate/' + templateId,
    method: 'get'
  });
};

/**
 * 新增电梯保养模板
 * @param data
 */
export const addUpkeepTemplate = (data: UpkeepTemplateForm) => {
  return request({
    url: '/iot/upkeepTemplate',
    method: 'post',
    data: data
  });
};

/**
 * 修改电梯保养模板
 * @param data
 */
export const updateUpkeepTemplate = (data: UpkeepTemplateForm) => {
  return request({
    url: '/iot/upkeepTemplate',
    method: 'put',
    data: data
  });
};

/**
 * 删除电梯保养模板
 * @param templateId
 */
export const delUpkeepTemplate = (templateId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/upkeepTemplate/' + templateId,
    method: 'delete'
  });
};
